package neusoft.edu.cn.a215lmeordering.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.squareup.picasso.Picasso;

import java.util.List;

import neusoft.edu.cn.a215lmeordering.R;
import neusoft.edu.cn.a215lmeordering.ViewHolder.ContentItemViewHolder;
import neusoft.edu.cn.a215lmeordering.ViewHolder.ShopFoodItemViewHolder;
import neusoft.edu.cn.a215lmeordering.bean.Content;
import neusoft.edu.cn.a215lmeordering.bean.Food;
import neusoft.edu.cn.a215lmeordering.iface.OnItemClickListener;

public class ContentAdapter extends RecyclerView.Adapter<ContentItemViewHolder> {
    private List<Content> contentList;
    String name;

    public void setDate(List<Content> dateItemList){
        this.contentList=dateItemList;
        notifyDataSetChanged();//通知数据集发生变化
    }

    @NonNull
    @Override
    public ContentItemViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        LayoutInflater layoutInflater = LayoutInflater.from(viewGroup.getContext());
        View itemView = layoutInflater.inflate(R.layout.itemcontent_layout,viewGroup,false);
        ContentItemViewHolder viewHolder = new ContentItemViewHolder(itemView);
        return viewHolder;

    }

    @Override
    public void onBindViewHolder(@NonNull final ContentItemViewHolder itemViewHolder, final int i) {
        final Content List = contentList.get(i);

        itemViewHolder.content_name.setText("张三李四");
        itemViewHolder.content_time.setText(List.getComment_time());
        itemViewHolder.content.setText(List.getContent());

    }

    @Override
    public int getItemCount() {
        if(contentList!=null)
            return contentList.size();
        else
            return 0;
    }
}
